package cn.edu.suse.epilepsy.config;

import cn.edu.suse.epilepsy.interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: QingShu
 * @Date: 2024/7/5 16:04
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
//    @Autowired
//    private TokenInterceptor tokenInterceptor;
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(tokenInterceptor)
//                .addPathPatterns("/**")
//                .excludePathPatterns("/sysuser/login")
//                .excludePathPatterns("/sysuser/register")
//                .excludePathPatterns("/doctormanage/*")
//                .excludePathPatterns("/depinfo/*")
//                .excludePathPatterns("/activity/*")
//                .excludePathPatterns("/signup/*")
//                .excludePathPatterns("/caseStd")
//                .excludePathPatterns("/caseStd/*")
//                .excludePathPatterns("/patient/*")
//                .excludePathPatterns("/patient")
//                .excludePathPatterns("/signup")
//                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**")
//        ;
//    }
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowCredentials(false)
                .allowedHeaders("*")
                .allowedOrigins("*")
                .allowedMethods("*")
                .maxAge(3600);

    }
}
